package cn.zf.spring.service;

import cn.zf.spring.dao.BookDao;
import cn.zf.spring.entity.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookService {

    //注入Dao
    @Autowired
    private BookDao bookDao;

    //增
    public void addBook(Book book){
        bookDao.add(book);
    }

    public void batchAdd(List<Object[]> batchArgs){
        bookDao.batchAddBook(batchArgs);
    }

    //删
    public void delBook(String id){
        bookDao.del(id);
    }
    public void batchDel(List<Object[]> batchArgs){
        bookDao.batchDelBook(batchArgs);
    }

    //改
    public void updateBook(Book book){
        bookDao.update(book);
    }
    public void batchUpdate(List<Object[]> batchArgs){
        bookDao.batchUpdateBook(batchArgs);

    }

    //查
    public void selectCount(){
        int i = bookDao.selectCount();
        System.out.println("本表共有" + i + "条数据");
    }

    public Book selectBook(String id){
        Book book = bookDao.findBookInfo(id);
        return book;
    }

    public List<Book> selectAllBook(){
        List<Book> allBook = bookDao.findAllBook();
        return allBook;
    }


}
